//
//  PYStudyRNDetailController.m
//  IHome
//
//  Created by 朱吉峥 on 2020/2/1.
//  Copyright © 2020 com.zhujizheng. All rights reserved.
//

#import "PYStudyRNDetailController.h"
#import <React/RCTRootView.h>
#import "PYRNBridge.h"
#import "PYRNEvent.h"

@interface PYStudyRNDetailController ()

@property (nonatomic, strong) PYRNEvent *event;
@property (nonatomic, copy) NSString *module;
@end

@implementation PYStudyRNDetailController

+ (instancetype)createWithModule:(NSString *)module
{
    PYStudyRNDetailController *controller = [PYStudyRNDetailController new];
    controller.title = module;
    controller.module = module;
    [controller initEvent];
    return controller;
}

- (void)initEvent
{
    self.event = [[PYRNEvent alloc] init];
    self.event.bridge = [PYRNBridge sharedBridge];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self addRightBarButtonItemWithTitle:@"测试" action:@selector(test)];

    RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:[PYRNBridge sharedBridge]
                                                     moduleName:self.module
                                              initialProperties:@{
                                                  @"keyword":@[@"同人故事", @"子女养成", @"宠物养成", @"活动玩法", @"门派杂谈"],
                                                  @"dataList":@[@{@"id":@"1",
                                                                  @"title":@"关于高等级魔王竞技如何上排行",
                                                                  @"content":@"本人130+资深魔王玩家一枚，从神武手游刚刚出就一直在跟着游戏步伐走，虽然期间...",
                                                                  @"img":@"http://a3.att.hudong.com/68/61/300000839764127060614318218_950.jpg",
                                                                  @"name":@"霸气太子妃",
                                                                  @"time":@"3分钟前",
                                                                  @"thumbup":@"184",
                                                                  @"comment":@"127"},
                                                                @{@"id":@"2",
                                                                  @"title":@"[仰慕]鼠年吉祥，耗时一个月弄出来了",
                                                                  @"content":@"一个月的心血，没存神兽，就弄这个老鼠了，吃了47个元宵，音波太难打了，放弃了...",
                                                                  @"img":@"http://a3.att.hudong.com/68/61/300000839764127060614318218_950.jpg",
                                                                  @"name":@"秃哥",
                                                                  @"time":@"45分钟前",
                                                                  @"thumbup":@"61",
                                                                  @"comment":@"133"},
                                                                @{@"id":@"3",
                                                                  @"title":@"元宵排名活动攻略",
                                                                  @"content":@"元宵活动使用搜索慢慢来，相信大家拿到高级元宵福袋已经没什么问题了，而排名奖励每...",
                                                                  @"img":@"http://a3.att.hudong.com/68/61/300000839764127060614318218_950.jpg",
                                                                  @"name":@"小豆豆",
                                                                  @"time":@"5小时前",
                                                                  @"thumbup":@"4",
                                                                  @"comment":@"1"},
                                                                @{@"id":@"4",
                                                                  @"title":@"神宠技能之“业报轮回”",
                                                                  @"content":@"最近想给大家分享一下，小编总结的一只可以从低级带到高级，并且性价比还不逊的宠物...",
                                                                  @"img":@"http://a3.att.hudong.com/68/61/300000839764127060614318218_950.jpg",
                                                                  @"name":@"林深时见鹿",
                                                                  @"time":@"8小时前",
                                                                  @"thumbup":@"1",
                                                                  @"comment":@"0"},
                                                                @{@"id":@"5",
                                                                  @"title":@"龙宫灭门，建议全民土吸收。",
                                                                  @"content":@"今天一条突然发现，原来龙宫这么废，双龙秒二800对比武侯秒三1200真的受伤，...",
                                                                  @"img":@"",
                                                                  @"name":@"一生傲慢",
                                                                  @"time":@"02-09",
                                                                  @"thumbup":@"49",
                                                                  @"comment":@"81"},
                                                                @{@"id":@"6",
                                                                  @"title":@"换区",
                                                                  @"content":@"哪个区好",
                                                                  @"img":@"",
                                                                  @"name":@"轻鸟小宝",
                                                                  @"time":@"02-09",
                                                                  @"thumbup":@"14",
                                                                  @"comment":@"9"},
                                                  ]
                                              }];
    self.view = rootView;
}

- (void)test
{
//    [PYRNUpdate uploadJsBundle];
//    [RNMethodTool emitMethod];
//    [PYRNEvent sendAlertNameWithBody:@{@"title":@"haha"}];
}

- (void)addNotifications
{
    [super addNotifications];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pushToNextController) name:@"PYRNPushToNextControllerNotification" object:nil];
}

- (void)pushToNextController
{
    PYViewController *controller = [PYViewController new];
    [self.navigationController pushViewController:controller animated:YES];
}
@end
